package com.example;

import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.*;
/**
	This class menatains information about the 
	users joining to the system.
*/
public class UserInfo {

	private String username;                                               //username of the user
	private String password;                                                //password of the user
	private String IP;                                                      //IP address of the user
	private int port;                                                        //port of the user
	private int id;                                                         //port of the user
	private ArrayList<String>grp = new ArrayList<String>();                  //group/groups of the user
	private ObjectOutputStream out;                                         //Object Output stream of the user
	private ObjectInputStream in;                                          //Object Input stream of the user
	private boolean isActive;                                              //checks if the user is active
	private boolean isTalking;
	
	public boolean isTalking() {
		return isActive;
	}

	public void setTalking(boolean isTalking) {
		this.isTalking = isTalking;
	}
	
	/**
	 * checks if the current user is active
	 * @return
	 */
	public boolean isActive() {
		return isActive;
	}

	/**
	 * sets the current activeState of the user
	 * @param isActive
	 */
	public void setActive(boolean isActive) {
		this.isActive = isActive;
	}

	/**
	 * returns the arraylist containing group of the user which can be more than one
	 * @return
	 */
	public ArrayList<String> getGrp() {
		return grp;
	}

	/**
	 * sets the group of the user
	 * @param val
	 */
	public void setGrp(String val) {
		grp.add(new String(val));
	}

	/**
	 * returns theObjectOutput stream of the user
	 * @return
	 */
	public ObjectOutputStream getOut() {
		return out;
	}

	/**
	 * sets the objectOutput stream of the user
	 * @param out
	 */
	public void setOut(ObjectOutputStream out) {
		this.out = out;
	}

	/**
	 * returns the object input stream of the user
	 * @return
	 */
	public ObjectInputStream getIn() {
		return in;
	}

	/**
	 * Sets the object input stream of the user
	 * @param in
	 */
	public void setIn(ObjectInputStream in) {
		this.in = in;
	}
	
	
	/**
	 * Returns the username of the user 
	 * @return the username
	 */
	public String getUsername() {
		return username;
	}

	/**
	 * @param username the username to set
	 */
	public void setUsername(String username) {
		this.username = new String(username);
	}

	/**
	 * @return the password
	 */
	public String getPassword() {
		return password;
	}

	/**
	 * @param password the password to set
	 */
	public void setPassword(String password) {
		this.password = new String(password);
	}

	/**
	 * @return the iP
	 */
	public String getIP() {
		return IP;
	}

	/**
	 * @param iP the iP to set
	 */
	public void setIP(String iP) {
		IP = new String(iP);
	}

	/**
	 * @return the port
	 */
	public int getPort() {
		return port;
	}

	/**
	 * @param port the port to set
	 */
	public void setPort(int port) {
		this.port = port;
	}

	/**
	 * @return the id
	 */
	public int getId() {
		return id;
	}

	/**
	 * sets the id of the user.
	 * @param id the id to set
	 */
	public void setId(int id) {
		this.id = id;
	}

	/**
	 * prints the user information
	 */
	public void print(){
		System.out.println("Username ==>"+username);
		System.out.println("Password ==>"+password);
		System.out.println("IP ==>"+IP);
		System.out.println("Port ==>"+port);
		System.out.println("ID ==>"+id);
		System.out.println("InStream ==>"+in);
		System.out.println("OutStream ==>"+out);
		System.out.println("Active ==>"+isActive);
		Iterator itr = grp.iterator();
		while(itr.hasNext())
			System.out.print(itr.next()+" ");
		System.out.println("");
	}
}